package com.exam.test;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.BeanUtils;

import java.math.BigDecimal;
import java.util.HashMap;

public class Student {
    //帮我建立main函数
    public static void main(String[] args) {
        HashMap<String, Object> map1 = new HashMap<>();
        map1.put("AAA",new Float(7.9));


        HashMap<String, Object> map2 = new HashMap<>();
        map2.put("AAA",new Integer(8));

        BeanUtils.copyProperties( map2,map1);

        System.out.println(map1);

        //
        Test1 test1 = new Test1();
        test1.setName("张三");
        test1.setAge("12h");

        Test2 test2 = new Test2();
        BeanUtils.copyProperties(test1,test2);
        System.out.println(JSONUtil.toJsonStr(test2));

        BeanUtil.copyProperties(test1,test2);

        System.out.println("111:"+ JSONUtil.toJsonStr(test2));
    }

    protected   static class Test1{
        String name;
        String age;

        public void setAge(String age) {
            this.age = age;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public String getAge() {
            return age;
        }

        public Test1() {
            this.name = name;
        }
    }

    protected   static class Test2{
        String name;
        BigDecimal age;

        public Test2(String name) {
            this.name = name;
        }

        public Test2() {

        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public BigDecimal getAge() {
            return age;
        }

        public void setAge(BigDecimal age) {
            this.age = age;
        }
    }
}
